{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="{:url('Events/index')}?nav=events-eventslist">新闻事件分类</a>
  <a><cite>{if !empty($data_list['id']) }编辑{else/}添加{/if}新闻事件分类</cite></a>
</span>
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        <div style="color:#FF5722">{if !empty($data_list['id']) }编辑{else/}添加{/if}新闻事件分类,返回页面后请刷新</div>
        <div class="layui-form">
         <form class="layui-form" action="" style='padding:10px;'>
          <div class="layui-form-item">
            <label class="layui-form-label">分类名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" value="{if !empty($data_list['title']) }{$data_list['title']}{/if}" autocomplete="off" placeholder="请输入分类名称" class="layui-input">
            </div>
          </div>
         <div class="layui-form-item">
             <label class="layui-form-label">分类英文名</label>
             <div class="layui-input-block">
                 <input type="text" name="title_en" value="{if !empty($data_list['title_en']) }{$data_list['title_en']}{/if}" autocomplete="off" placeholder="请输入分类英文名称" class="layui-input">
             </div>
         </div>
         <div class="layui-form-item">
             <label class="layui-form-label">排序</label>
             <div class="layui-input-block">
                 <input type="text" name="seq" value="{if !empty($data_list['seq']) }{$data_list['seq']}{/if}" autocomplete="off" placeholder="请输入排序" class="layui-input">
             </div>
         </div>

          
          <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
              <button type="button" class="layui-btn layui-btn-sm" onclick="insert_edit({if !empty($data_list['class_id']) }{$data_list['class_id']}{else/}'tj'{/if})">确 定</button>
            </div>
          </div>
          
        </form>

        </div>
      </div>  
    </div>
</div>
{include file="/public/footer" /}


<script charset="utf-8" src="/static/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
<script>
 

  function insert_edit(id){
      layer.load();
      var title=$.trim($("input[name='title']").val());
      var title_en=$.trim($("input[name='title_en']").val());
      var seq=$.trim($("input[name='seq']").val());
     
      if(title==''){
          layer.closeAll('loading');
          layer.msg('请填写标题');
          return false;
      }
      if(title_en==''){
          layer.closeAll('loading');
          layer.msg('请填写英文标题');
          return false;
      }
      if(seq==''){
          layer.closeAll('loading');
          layer.msg('请填写排序');
          return false;
      }


      if(id=='tj'){
        var url="{:url('Eventsclass/do_change')}";
      }else{
        var url="{:url('Eventsclass/do_change')}"+"?id="+id;
      }
      $.post(url,{title:title,title_en:title_en,seq:seq},function(res){
        if(res.status=='0'){
            layer.closeAll('loading');
            layer.msg(res.msg);
        }
        if(res.status=='1'){
            layer.msg(
            res.msg,{time: 1500 },
            function(){
              layer.closeAll();
              location.href=location.href;
            });
        }
    }) 
  }
</script>


